<template>
  <div class="sm-login">
    <img
      class="sm-login-text"
      src="@/assets/images/sm_login_text.png"
      @click="emits('changeLoginType')"
    />
    <img
      class="sm-login-icon"
      src="@/assets/images/sm_login.png"
      alt=""
      @click="emits('changeLoginType')"
    />
  </div>
  <div class="login-form-wrapper">
    <div class="login-form-title">{{ $t('login.form.title') }}</div>
    <div class="login-form-sub-title">{{ $t('login.form.title') }}</div>
    <div class="login-form-error-msg">{{ errorMessage }}</div>
    <a-tabs type="rounded">
      <a-tab-pane key="1" title="密码登录">
        <password-form @login-success="emits('loginSuccess')" />
      </a-tab-pane>
      <a-tab-pane key="2" title="手机号登录">
        <phone-form />
      </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script lang="ts" setup>
  import { ref, defineEmits } from 'vue';
  import PasswordForm from '@/views/login/components/password-form.vue';
  import PhoneForm from '@/views/login/components/phone-form.vue';

  const emits = defineEmits(['loginSuccess', 'changeLoginType']);

  const errorMessage = ref('');
</script>

<style lang="less" scoped>
  .login-form {
    &-wrapper {
      width: 320px;
    }

    &-title {
      color: var(--color-text-1);
      font-weight: 500;
      font-size: 24px;
      line-height: 32px;
    }

    &-sub-title {
      color: var(--color-text-3);
      font-size: 16px;
      line-height: 24px;
    }

    &-error-msg {
      height: 32px;
      color: rgb(var(--red-6));
      line-height: 32px;
    }

    &-password-actions {
      display: flex;
      justify-content: space-between;
    }

    &-register-btn {
      color: var(--color-text-3) !important;
    }
  }
  .sm-login {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: end;

    &-icon {
      width: 50px;
      height: 50px;
      cursor: pointer;
    }

    &-text {
      height: 25px;
      cursor: pointer;
    }
  }
</style>

<style lang="less">
  .login-form-wrapper {
    .arco-tabs-nav-tab {
      justify-content: center;
    }
    .arco-tabs-nav-type-capsule .arco-tabs-nav-tab-list {
      width: 100%;
    }
    .arco-tabs-nav-tab-list {
      display: flex;
    }
    .arco-tabs-tab {
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
</style>
